#include <iostream>
#include <memory>
#include "jsoncpp/json/json.h"
using namespace std;
int main()
{
    // std::string str = "{\"姓名\":\"小明\", \"年龄\":18, \"成绩\":[76.5, 55, 88]}";//使用转义字符
    std::string str = R"({"姓名":"小明", "年龄":18, "成绩":[76.5, 55, 88]})"; // c++11新语法

    Json::Value root;
    Json::CharReaderBuilder crb;
    std::unique_ptr<Json::CharReader> cr(crb.newCharReader());
    std::string err;
    cr->parse(str.c_str(), str.c_str() + str.size(), &root, &err);
    std::cout << root["姓名"].asString() << std::endl;
    std::cout << root["年龄"].asInt() << std::endl;
    int sz = root["成绩"].size();
    
    for (auto it = root["成绩"].begin(); it != root["成绩"].end(); it++)
    {
        std::cout << it->asFloat() << std::endl;
    }
    return 0;
}